home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
asm
/
cm_int.exe
/
CM-MACS.LIB
< prev
next >
Wrap
Text File
|
1993-04-10
|
22KB
|
654 lines
; CM-MACS.LIB - By CFMartin - 2/15/90
;
; A Collection of Standard Assembly Macros written for use with the
; Wolfware Assembler WASM, and the interrupt service provided by CM-INT.COM
;
; General Notes:
; 1. These macros are not necessarily compatible with any assembler
; except WASM.
; 2. Arguments for these macros are of two types, denoted by the
; suffixes "_lab" and "_imm", for "label" and "immediate," based
; on the expected most frequent usage.
; a. _lab indicates that the macro is looking for a
; label for a memory operand in the data segment.
; b. _imm indicates that the macro is looking for an immediate
; operand. To reference memory in the data segment, just
; enclose the operand label in brackets.
; 3. Names and syntax of some macros will look very familiar to
; C programmers, as they are patterned after standard C functions
; VIDEO/KEYBOARD MANAGEMENT
;------------------
vpage macro vpage_imm ;selects video page
;------------------
; vpage_imm byte video page number to be selected
;------------------
mov ah,5
mov al,vpage_imm
int 10h
endm
;------------------
vmode macro vmode_imm ;sets video mode
;------------------
; vmode_num byte video mode number
;------------------
mov ah,0
mov al,vmode_imm
int 10h
endm
;------------------
poscurs macro row_imm,column_imm ;positions cursor on active page (mode 2,3)
;------------------
; row_imm,column_imm bytes 0,0=upper left corner
;------------------
mov ah,0Fh ;get video state
int 10h
mov ah,2 ;service 2 -- position cursor
mov dh,row_imm ;bh contains page
mov dl,column_imm
int 10h ;set cursor
endm
;------------------
clrscrn macro color_imm ;clears active screen page (mode 2,3)
;------------------
; color_imm byte attribute to clear screen with
;------------------
mov ah,0Fh ;get video state
int 10h
mov al,bh ;page
mov ah,0
mov bx,100h ;256 paras per page modes 2 & 3
mul bx
add ax,0B800h ;seg of page 0
mov es,ax
mov dl,color_imm
mov di,0
mov ah,dl
mov cx,2000
mov al,20h ;blank
cld
rep
stosw
endm
;------------------
pause macro key_name_imm ;pauses until the named key is pressed
;------------------
; key_name_imm byte key to wait for
;------------------
mov bl,byte key_name_imm
mov bh,00h
int 0C0h
endm
;------------------
print macro str_lab ;print string at current cursor pos on active page
;------------------
; str_lab byte label of ASCIIZ string to print
;------------------
lea si,str_lab
mov bh,01h
int 0C0h
endm
;------------------
input macro str_lab ;input string to <Rtn> with echo to active page
;------------------
; str_lab byte label of ASCIIZ destination string
;------------------
lea si,str_lab
mov bh,02h
int 0C0h
endm
;------------------
scan macro prompt_lab,data_lab,data_len_imm
;------------------
; prompt_lab byte label of ASCIIZ prompt string
; data_lab byte label of ASCIIZ dest string for input
; data_len_imm byte unsigned length of dest string
; (Use no filtering, no blank stripping, window color 0Fh)
;------------------
lea si,prompt_lab
lea di,data_lab
mov al,data_len_imm
mov ah,0 ;no input data filtering
mov cl,0 ;no blank stripping
mov ch,0Fh ;window color=hi intens wh, blk bkgd
mov bx,300h ;upper and lower case accepted
int 0C0h
endm
;------------------
lprint macro str_lab
;------------------
; Prints ASCIIZ string at ds:offset str_lab to parallel printer
;------------------
mov cx,-1
lea si,str_lab
mov bh,4
int 0C0h
endm
;------------------
lprintc macro ctrl_str_lab
;------------------
; Prints printer control string at ds:offset ctrl_str_lab to parallel printer
; First byte of control string is length; remainder is string
;------------------
mov cl,[ctrl_str_lab]
xor ch,ch
lea si,ctrl_str_lab
inc si
mov bh,4
int 0C0h
endm
; NUMERICAL CONVERSION
;------------------
ltoa macro dw_lab,str_lab ;convert 32-bit number to decimal ASCIIZ string
;------------------
; dw_lab double word 32-bit number to be converted
; str_lab byte label of ASCIIZ dest string in ds
;------------------
lea si,str_lab
mov ax,[offset dw_lab] ;low order 16 bits
mov dx,[offset dw_lab+2] ;high order 16 bits,
;including sign (bit 31)
mov bl,0 ;decimal return
mov bh,06h
int 0C0h
endm
;------------------
ltoa2 macro dw_lab,str_lab,base_imm ;convert with base option
;------------------
; dw_lab double word 32-bit number to be converted
; str_lab byte label of ASCIIZ dest string in ds
; base_imm byte dec=0,hex=1,oct=2,bin=3
;------------------
lea si,str_lab
mov ax,[offset dw_lab] ;low order 16 bits
mov dx,[offset dw_lab+2] ;high order 16 bits,
;including sign (bit 31)
mov bl,base_imm
mov bh,06h
int 0C0h
endm
;------------------
atol macro dw_lab,str_lab ;conv string to 32-bit d-word
;------------------
; dw_lab double word 32-bit number to be converted
; str_lab byte label of ASCIIZ source string in ds
;------------------
lea si,str_lab
mov bh,07h
int 0C0h
mov [offset dw_lab],ax ;low order 16-bits
mov [offset dw_lab+2],dx ;high order 16-bits
endm
;------------------
itoa macro w_lab,str_lab ;conv signed 16-bit word to dec string
;------------------
; w_lab word signed 16-bit number to be converted
; str_lab byte label of ASCIIZ dest string in ds
;------------------
lea si,str_lab
mov ax,[offset w_lab] ;16-bit signed no.
cwd ;extend to d-word
mov bl,0 ;return decimal
mov bh,06h
int 0C0h
endm
;------------------
itoa2 macro w_lab,str_lab,base_imm ;conv signed 16-bit word to string
;------------------
; w_lab word signed 16-bit number to be converted
; str_lab byte label of ASCIIZ dest string in ds
; base_imm byte dec=0,hex=1,oct=2,bin=3
;------------------
lea si,str_lab
mov ax,[offset w_lab] ;16-bit signed no.
cwd ;extend to d-word
mov bl,base_imm
mov bh,06h
int 0C0h
endm
;------------------
atoi macro w_lab,str_lab ;conv string to signed 16-bit
;------------------
; w_lab word signed 16-bit number to be converted
; str_lab byte label of ASCIIZ source string in ds
;------------------
lea si,str_lab
mov bh,07h
int 0C0h